<?php
/*
	插件链接选择页面
*/
defined('BY_JYA') or exit('error');
//系统链接获取接口
$return=array();
$_RQ['op']=$_RQ['op']?$_RQ['op']:'list';
$tabs=array(
	array('op'=>'system','plugin'=>'core','action'=>'tools.link','title'=>'系统页面链接'),
	array('op'=>'groups','title'=>'商品'),
	array('op'=>'list','title'=>'插件页面'),
);
if($_RQ['op']=='list'){
	$return['list']=array();
	$return['list'][]=array('title'=>'首页','url'=>'jy_city/index/');
	$return['list'][]=array('title'=>'分销中心','url'=>'jy_city/agent.index/');
	$return['list'][]=array('title'=>'会员中心','url'=>'jy_city/myhome/');
	$return['list'][]=array('title'=>'商品列表','url'=>'jy_city/goods.index/');
	$return['list'][]=array('title'=>'红包','url'=>'jy_merch/red/');
	$return['list'][]=array('title'=>'活动','url'=>'jy_merch/game/');
	$return['list'][]=array('title'=>'我的商家','url'=>'jy_merch/member.mymerch/');
	$return['list'][]=array('title'=>'我的会员','url'=>'jy_merch/member.mymember/');
	foreach($this->merch_types2 as $k=>$mv){
		$return['list'][]=array('title'=>$mv,'url'=>'jy_merch/merchlist//type='.$k);
	}
	$htmls=array(
		'type'=>'list',
		'tabs'=>$tabs,
		'list'=>array('data'=>'list','edit'=>false,'delall'=>false,'del_one'=>false,'pagelist'=>false,'list'=>array(
			array('name'=>'title','title'=>'标题','type'=>'string'),
			array('name'=>'url','title'=>'地址','type'=>'string'),
		),'action'=>array(
			array('type'=>'modal_result','name'=>'url','title'=>'选取'),
		)),
		'search_one'=>array('name'=>'title','add'=>false),
	);
	$return['htmls']=$htmls;
	exi($return);
}
if($_RQ['op']=='groups'){
	$params=array();
	$params['uniacid']=$_SESSION['uniacid'];
	$params['status']='1';
	if(!empty($_RQ['title'])){
		$params['title like']='%'.trim($_RQ['title']).'%';
		$return['params']['title']=$_RQ['title'];
	}
	$pindex = max(1, intval($_RQ['page']));
	$psize = 10;
	$total='';
	$list=pdo_getslice('jy_weishop_goods_group',$params,array($pindex,$psize),$total,$fields,'','id desc');
	if($list){
		foreach($list as &$item){
			$item['url']='jy_city/goods.index//pid='.$item['id'];
		}
	}
	$return['list']=$list;
	$totalpage=ceil($total/$psize);
	$totalpage=intval($totalpage);
	$return['totalpage'] =$totalpage;
	$return['params']['page'] =$pindex;
	$htmls=array(
		'type'=>'list',
		'tabs'=>$tabs,
		'list'=>array('data'=>'list','edit'=>false,'delall'=>false,'del_one'=>false,'pagelist'=>false,'list'=>array(
			array('name'=>'title','title'=>'标题','type'=>'string'),
			array('name'=>'url','title'=>'短地址','type'=>'string'),
		),'action'=>array(
			array('type'=>'modal_result','name'=>'url','title'=>'选取'),
		)),
		'search_one'=>array('name'=>'title','add'=>false),
	);	
	$return['htmls']=$htmls;
	exi($return);
}